import { Controller, Get, Inject } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { AppService } from './app.service';
import { WINSTON_LOGGER_TOKEN } from './modules/logger/logger.module';

@Controller({
  version: '1',
})
export class AppController {
  constructor(
    private readonly appService: AppService,
    @Inject('person1') private readonly person1: { name: string; age: number },
    @Inject('person4') private readonly person4: { name: string; age: number },
  ) {}

  @Inject(WINSTON_LOGGER_TOKEN)
  private logger;

  @Inject('person2')
  private person2: { name: string; age: number };

  @Inject('person3')
  private person3: { name: string; desc: string };

  @Inject('person5')
  private person5: { name: string; age: number };

  @Inject(ConfigService)
  private configService: ConfigService;

  @Get()
  getHello() {
    return {
      // aaa: this.configService.get('aaa'),
      // bbb: this.configService.get('bbb'),
      db: this.configService.get('db')
    }
  }

  @Get()
  test(): string {
    this.logger.log('hello', AppController.name);
    return (
      this.appService.test() +
      this.person1.name +
      this.person2.name +
      this.person3.desc +
      this.person4.name +
      this.person5.name
    );
  }

  @Get('/testVersion')
  testVersion() {
    return '版本1';
  }
}
